#ifndef __PCA6416_H__
#define __PCA6416_H__

#include "drv_log.h"

#ifdef STATIC_SKIP
#define STATIC
#else
#define STATIC static
#endif

#define PC6416_LOG_PREFIX "pca6416"
#define pca6416_err(fmt...) drv_err(PC6416_LOG_PREFIX, fmt)
#define pca6416_warn(fmt...) drv_warn(PC6416_LOG_PREFIX, fmt)
#define pca6416_info(fmt...) drv_info(PC6416_LOG_PREFIX, fmt)
#define pca6416_debug(fmt...) drv_debug(PC6416_LOG_PREFIX, fmt)

#define PCA6416_IOC_MAGIC 'P'
#define IIC_PCA_IOCTL_GET_BOARD_ID _IOR(PCA6416_IOC_MAGIC, 61, int)
#define IIC_PCA_IOCTL_GET_PCB_ID _IOR(PCA6416_IOC_MAGIC, 62, int)
#define IIC_PCA_IOCTL_GET_BOM_ID _IOR(PCA6416_IOC_MAGIC, 63, int)
#define IIC_PCA_IOCTL_GET_TYPE_ID _IOR(PCA6416_IOC_MAGIC, 64, int)

#define PCA6416_I2C_MINORS 1
#define PCA6416_NAME "PCA6416"
#define I2C_PCA6416_ADDR (0x20)
#define I2C_NAME(x) (x)->name
#define BOARD_INFO_CMD (0x00)
#define PCB_INFO_CMD (0x01)
#define BOM_INFO_CMD (0x01)
#define IOMUX_REG_ADDR (0x0110080000)
#define IOMUX_REG_LEN (0x18)
#define IOMUX_REG_10_OFFSET (0x10)
#define IOMUX_REG_14_OFFSET (0x14)
#define IOMUX_I2C_VALUE (0x02)
#define PCA6416_READ_BUF_LEN (1)
#define PCA6416_SEND_BUF_LEN (1)
#define PCA6416_TYPE_ID_BITS (6)
#define PCA6416_DELAY_MS (5)
#define PCA6416_PCB_ID_BITS (4)
#define PCA9555_PCB_ID_BITS (3)
#define BOARD_ID_TYPE_MASK (0x3)
#define BOARD_ID_DEVELOP_C_MASK (0x7)
#define BOARD_ID_DEVELOP_A_MASK (0xF)
#define BOARD_ID_DEVELOP_C (0xCE)
#define BOARD_ID_DEVELOP_A (0xCF)

struct PCA6416_dev {
    int minor;
    struct i2c_adapter *adap;
    struct i2c_client *client;
    struct mutex mutex;
};

#ifdef STATIC_SKIP
STATIC void __exit PCA6416_exit(void);
STATIC int __init PCA6416_init(void);
STATIC int PCA6416_remove(struct i2c_client *client);
STATIC int PCA6416_probe(struct i2c_client *client, const struct i2c_device_id *id);
STATIC long PCA6416_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
STATIC int PCA6416_release(struct inode *node, struct file *file);
STATIC int PCA6416_open(struct inode *node, struct file *file);
STATIC struct PCA6416_dev *i2c_dev_get_by_minor(unsigned index);
STATIC struct PCA6416_dev *i2c_dev_get_by_adapter(struct i2c_adapter *adap);
STATIC int return_i2c_dev(struct PCA6416_dev *i2c_dev);
STATIC struct PCA6416_dev *get_free_i2c_dev(struct i2c_adapter *adap);
#endif

#endif
